define(function() {
    // 模块代码s
    var utils={};


    //获得主键uuid
    utils.getUUID=function(){
        return Math.uuid();
    }

    utils.checkUndefined=function(param){
        var params="";
        if(param == undefined || param == "undefined" || param == null || param == "null" || param ==""){
            params= "未设定"
        }else{
           params=param;
        }
       return params;
    }

    utils.getNowDateTime=function(){
        var d=new Date();
        return d.format('yyyy-MM-dd hh:mm:ss');
    }

    utils.getCheckData=function(){
        var params="";
        $("input[dote='checkbox']").each(function(){
            var check=$(this).attr("checked");
            var id=$(this).attr("id");
            if(check == "checked"){
                params+=id+",";
            }
        })
        params=params.substring(0,params.length-1);
        return params;
    }

    utils.getIP=function(){
        return "http://192.168.1.69:3000/";
    }

    //------------------String类

    utils.json2string = function(json){
       return JSON.stringify(json);
    }

    utils.string2json = function(str){
        return JSON.parse(str);
    }

    utils.GetQueryString=function(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) {
            return unescape(r[2]);
        }else{
            return null;
        }
    }


    //------------------本地存储类
    utils.saveItem = function(key,value){
        localStorage.setItem("BOCRPS_"+key,value);
    }
    utils.getItem = function(key){
        return localStorage.getItem("BOCRPS_"+key);
    }

    utils.href = function(href){
        window.location.href = href+"?v="+new Date().getTime();
    }


    //------------------日期类
    utils.num2DateString = function (num) {
        return new Date(parseInt(num)).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
    }


    //------------------安全类
    utils.createUUID = (function (uuidRegEx, uuidReplacer) {
        return function () {
            return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase();
        };
    })(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0,
            v = c =="x"? r : (r & 3 | 8);
        return v.toString(16);
    });


    return utils;
});

